g_clear_pointer (&self->cached_meta_indexes, (GDestroyNotify) g_ptr_array_unref);
g_clear_pointer (&self->cached_content_indexes, (GDestroyNotify) g_ptr_array_unref);
g_mutex_clear (&self->cache_lock);
+ g_mutex_clear (&self->txn_stats_lock);
G_OBJECT_CLASS (ostree_repo_parent_class)->finalize (object);
}
ostree_repo_init (OstreeRepo *self)
{
g_mutex_init (&self->cache_lock);
+ g_mutex_init (&self->txn_stats_lock);
}
OstreeRepo*
g_clear_object (&temp_file);
}
}
+
+ g_mutex_lock (&self->txn_stats_lock);
+ if (do_commit)
+ {
+ if (OSTREE_OBJECT_TYPE_IS_META (objtype))
+ {
+ self->txn_metadata_objects_written++;
+ }
+ else
+ {
+ self->txn_content_objects_written++;
+ self->txn_content_bytes_written += file_object_length;
+ }
+ }
+ if (OSTREE_OBJECT_TYPE_IS_META (objtype))
+ self->txn_metadata_objects_total++;
+ else
+ self->txn_content_objects_total++;
+ g_mutex_unlock (&self->txn_stats_lock);
if (checksum)
ret_csum = ot_csum_from_gchecksum (checksum);
else
ret_transaction_resume = FALSE;
+ self->txn_metadata_objects_total =
+ self->txn_metadata_objects_written =
+ self->txn_content_objects_total =
+ self->txn_content_objects_written =
+ self->txn_content_bytes_written = 0;
+
self->in_transaction = TRUE;
if (ret_transaction_resume)
{
return ret;
}
-gboolean
-ostree_repo_commit_transaction (OstreeRepo *self,
- GCancellable *cancellable,
- GError **error)
+gboolean
+ostree_repo_commit_transaction_with_stats (OstreeRepo *self,
+ guint *out_metadata_objects_total,
+ guint *out_metadata_objects_written,
+ guint *out_content_objects_total,
+ guint *out_content_objects_written,
+ guint64 *out_content_bytes_written,
+ GCancellable *cancellable,
+ GError **error)
{
gboolean ret = FALSE;
g_hash_table_remove_all (self->loose_object_devino_hash);
self->in_transaction = FALSE;
+ if (out_metadata_objects_total) *out_metadata_objects_total = self->txn_metadata_objects_total;
+ if (out_metadata_objects_written) *out_metadata_objects_written = self->txn_metadata_objects_written;
+ if (out_content_objects_total) *out_content_objects_total = self->txn_content_objects_total;
+ if (out_content_objects_written) *out_content_objects_written = self->txn_content_objects_written;
+ if (out_content_bytes_written) *out_content_bytes_written = self->txn_content_bytes_written;
ret = TRUE;
out:
return ret;
}
+gboolean
+ostree_repo_commit_transaction (OstreeRepo *self,
+ GCancellable *cancellable,
+ GError **error)
+{
+ return ostree_repo_commit_transaction_with_stats (self, NULL, NULL, NULL, NULL, NULL,
+ cancellable, error);
+}
+
gboolean
ostree_repo_abort_transaction (OstreeRepo *self,
GCancellable *cancellable,
g_object_unref (asyncdata->result);
}
+/**
+ * ostree_repo_stage_content_finish:
+ * @self: a #OstreeRepo
+ * @result: a #GAsyncResult
+ * @out_csum: (out) (transfer full): A binary SHA256 checksum of the content object
+ * @error: a #GError
+ *
+ * Completes an invocation of ostree_repo_stage_content_async().
+ */
gboolean
ostree_repo_stage_content_finish (OstreeRepo *self,
GAsyncResult *result,
return FALSE;
data = g_simple_async_result_get_op_res_gpointer (simple);
- /* Transfer ownership */
- *out_csum = data->result_csum;
- data->result_csum = NULL;
+ ot_transfer_out_value (out_csum, &data->result_csum);
return TRUE;
}
}
static gboolean
-stage_directory_to_mtree_internal (OstreeRepo *self,
- GFile *dir,
- OstreeMutableTree *mtree,
- OstreeRepoCommitModifier *modifier,
- GPtrArray *path,
- GCancellable *cancellable,
- GError **error)
+stage_directory_to_mtree_internal (OstreeRepo *self,
+ GFile *dir,
+ OstreeMutableTree *mtree,
+ OstreeRepoCommitModifier *modifier,
+ GPtrArray *path,
+ GCancellable *cancellable,
+ GError **error)
{
gboolean ret = FALSE;
gboolean repo_dir_was_empty = FALSE;
goto out;
if (!stage_directory_to_mtree_internal (self, child, child_mtree,
- modifier, path, cancellable, error))
+ modifier, path,
+ cancellable, error))
goto out;
}
else if (repo_dir)
return ret;
}
+/**
+ * ostree_repo_stage_directory_to_mtree:
+ * @self:
+ * @dir: Path to a directory
+ * @mtree: Overlay directory contents into this tree
+ * @modifier: (allow-none): Optional modifier
+ * @cancellable:
+ * @error:
+ *
+ * Store objects for @dir and all children into the repository @self,
+ * overlaying the resulting filesystem hierarchy into @mtree.
+ */
gboolean
-ostree_repo_stage_directory_to_mtree (OstreeRepo *self,
- GFile *dir,
- OstreeMutableTree *mtree,
- OstreeRepoCommitModifier *modifier,
- GCancellable *cancellable,
- GError **error)
+ostree_repo_stage_directory_to_mtree (OstreeRepo *self,
+ GFile *dir,
+ OstreeMutableTree *mtree,
+ OstreeRepoCommitModifier *modifier,
+ GCancellable *cancellable,
+ GError **error)
{
gboolean ret = FALSE;
GPtrArray *path = NULL;
path = g_ptr_array_new ();
- if (!stage_directory_to_mtree_internal (self, dir, mtree, modifier, path, cancellable, error))
+ if (!stage_directory_to_mtree_internal (self, dir, mtree, modifier, path,
+ cancellable, error))
goto out;
ret = TRUE;
GCancellable *cancellable,
GError **error);
+gboolean ostree_repo_commit_transaction_with_stats (OstreeRepo *self,
+ guint *out_metadata_objects_total,
+ guint *out_metadata_objects_written,
+ guint *out_content_objects_total,
+ guint *out_content_objects_written,
+ guint64 *out_content_bytes_written,
+ GCancellable *cancellable,
+ GError **error);
+
gboolean ostree_repo_abort_transaction (OstreeRepo *self,
GCancellable *cancellable,
GError **error);
void ostree_repo_commit_modifier_unref (OstreeRepoCommitModifier *modifier);
-gboolean ostree_repo_stage_directory_to_mtree (OstreeRepo *self,
- GFile *dir,
- OstreeMutableTree *mtree,
- OstreeRepoCommitModifier *modifier,
- GCancellable *cancellable,
- GError **error);
-
-gboolean ostree_repo_stage_archive_to_mtree (OstreeRepo *self,
- GFile *archive,
- OstreeMutableTree *tree,
- OstreeRepoCommitModifier *modifier,
- gboolean autocreate_parents,
- GCancellable *cancellable,
- GError **error);
+gboolean ostree_repo_stage_directory_to_mtree (OstreeRepo *self,
+ GFile *dir,
+ OstreeMutableTree *mtree,
+ OstreeRepoCommitModifier *modifier,
+ GCancellable *cancellable,
+ GError **error);
+
+gboolean ostree_repo_stage_archive_to_mtree (OstreeRepo *self,
+ GFile *archive,
+ OstreeMutableTree *tree,
+ OstreeRepoCommitModifier *modifier,
+ gboolean autocreate_parents,
+ GCancellable *cancellable,
+ GError **error);
gboolean ostree_repo_stage_mtree (OstreeRepo *self,
OstreeMutableTree *tree,
static char **opt_trees;
static gint opt_owner_uid = -1;
static gint opt_owner_gid = -1;
+static gboolean opt_table_output;
static GOptionEntry options[] = {
{ "subject", 's', 0, G_OPTION_ARG_STRING, &opt_subject, "One line subject", "subject" },
{ "tar-autocreate-parents", 0, 0, G_OPTION_ARG_NONE, &opt_tar_autocreate_parents, "When loading tar archives, automatically create parent directories as needed", NULL },
{ "skip-if-unchanged", 0, 0, G_OPTION_ARG_NONE, &opt_skip_if_unchanged, "If the contents are unchanged from previous commit, do nothing", NULL },
{ "statoverride", 0, 0, G_OPTION_ARG_FILENAME, &opt_statoverride_file, "File containing list of modifications to make to permissions", "path" },
+ { "table-output", 0, 0, G_OPTION_ARG_NONE, &opt_table_output, "Output more information in a KEY: VALUE format", NULL },
{ NULL }
};
gboolean ret = FALSE;
gboolean skip_commit = FALSE;
gboolean in_transaction = FALSE;
+ guint metadata_total = 0;
+ guint metadata_written = 0;
+ guint content_total = 0;
+ guint content_written = 0;
+ guint64 content_bytes_written = 0;
gs_unref_object OstreeRepo *repo = NULL;
gs_unref_object GFile *arg = NULL;
gs_free char *parent = NULL;
&commit_checksum, cancellable, error))
goto out;
- if (!ostree_repo_commit_transaction (repo, cancellable, error))
+ if (!ostree_repo_commit_transaction_with_stats (repo,
+ &metadata_total,
+ &metadata_written,
+ &content_total,
+ &content_written,
+ &content_bytes_written,
+ cancellable, error))
goto out;
in_transaction = FALSE;
if (!ostree_repo_write_ref (repo, NULL, opt_branch, commit_checksum, error))
goto out;
- g_print ("%s\n", commit_checksum);
}
else
{
in_transaction = FALSE;
- g_print ("%s\n", parent);
+ commit_checksum = g_strdup (parent);
+ }
+
+ if (opt_table_output)
+ {
+ g_print ("Commit: %s\n", commit_checksum);
+ g_print ("Metadata Total: %u\n", metadata_total);
+ g_print ("Metadata Written: %u\n", metadata_written);
+ g_print ("Content Total: %u\n", content_total);
+ g_print ("Content Written: %u\n", content_written);
+ g_print ("Content Bytes Written: %" G_GUINT64_FORMAT "\n", content_bytes_written);
+ }
+ else
+ {
+ g_print ("%s\n", commit_checksum);
}
ret = TRUE;